package com.anjie.powerproject.strategy.pojo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.Date;

//每天的天气预测
@Entity (name = "weather_forecast_daily")
public class DayWeather {
    @Id
    private Date sdate;
    private Double temphigh;
    private Double templow;
    private Double wind;
    private Double humidity;

    @Column(name = "humidity_high")
    private Double humidityHigh;

    @Column(name = "humidity_low")
    private Double humidityLow;

    @JsonIgnore
    private Double weather;
    @JsonIgnore
    private String historycityCode;

    @Transient
    private String des;

    // 平均温度(temphigh + templow / 2)
    @Transient
    @JsonIgnore
    private Double tempavg;

    public DayWeather() {

    }

    public DayWeather(Date sdate, Double temphigh, Double templow, Double wind, Double humidity, Double weather, String historycityCode) {
        this.sdate = sdate;
        this.temphigh = temphigh;
        this.templow = templow;
        this.wind = wind;
        this.humidity = humidity;
        setWeather(weather);
        this.historycityCode = historycityCode;
    }

    public Date getSdate() {
        return sdate;
    }

    public void setSdate(Date sdate) {
        this.sdate = sdate;
    }

    public Double getTemphigh() {
        return temphigh;
    }

    public void setTemphigh(Double temphigh) {
        this.temphigh = temphigh;
    }

    public Double getTemplow() {
        return templow;
    }

    public void setTemplow(Double templow) {
        this.templow = templow;
    }

    public Double getWind() {
        return wind;
    }

    public void setWind(Double wind) {
        this.wind = wind;
    }

    public Double getHumidity() {
        return humidity;
    }

    public void setHumidity(Double humidity) {
        this.humidity = humidity;
    }

    public Double getWeather() {
        return weather;
    }

    public void setWeather(Double weather) {
        this.weather = weather;
    }

    public String getHistorycityCode() {
        return historycityCode;
    }

    public void setHistorycityCode(String historycityCode) {
        this.historycityCode = historycityCode;
    }

    public Double getTempavg() {
        return (this.temphigh + this.templow) / 2;
    }

    public void setTempavg() {
        this.tempavg = (this.temphigh + this.templow) / 2;
    }

    public void setTempavg(Double tempavg) {
        this.tempavg = tempavg;
    }

    public String getDes() {
        return des;
    }

    public Double getHumidityHigh() {
        return humidityHigh;
    }

    public void setHumidityHigh(Double humidityHigh) {
        this.humidityHigh = humidityHigh;
    }

    public Double getHumidityLow() {
        return humidityLow;
    }

    public void setHumidityLow(Double humidityLow) {
        this.humidityLow = humidityLow;
    }

    public void setDes() {
        switch (this.weather.intValue()) {
            case 0: this.des="晴天";break;
            case 1: this.des="多云";break;
            case 3: this.des="雨雪";break;
            case 2: this.des="多云";break;
        }
    }

    @Override
    public String toString() {
        return "DayWeather{" +
                "sdate=" + sdate +
                ", temphigh=" + temphigh +
                ", templow=" + templow +
                ", wind=" + wind +
                ", humidity=" + humidity +
                ", weather=" + weather +
                ", historycityCode='" + historycityCode + '\'' +
                ", des='" + des + '\'' +
                ", tempavg=" + tempavg +
                '}';
    }
}
